package com.example.qing.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.qing.mapper.AlbumMapper;
import com.example.qing.mapper.PhotoMapper;
import com.example.qing.mapper.UserMapper;
import com.example.qing.pojo.Album;
import com.example.qing.pojo.Photo;
import com.example.qing.pojo.User;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class AlbumService extends ServiceImpl<AlbumMapper, Album> {
    @Resource
    AlbumMapper albumMapper;

    @Resource
    PhotoMapper photoMapper;


    @Transactional(rollbackFor = Exception.class)
    public void deleteAlbum(Integer id) {
        QueryWrapper<Photo>queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("name",albumMapper.selectById(id).getAlbumName());
        photoMapper.delete(queryWrapper);
        albumMapper.deleteById(id);
    }
}
